package com.yj.lottery_system.dao.mapper;

import com.yj.lottery_system.dao.dataObject.ActivityDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity (activity_name, description, status) values (#{activityName}, #{description},#{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert (ActivityDO activityDO);
    /**
     * 查询活动总数
     * @return
     */
    @Select("select count(1) from activity")
    int count();

    /**
     * 查询当前页面的奖品列表
     * @param offset
     * @param pageSize
     * @return
     */
    @Select("select * from activity order by id desc limit ${offset}, #{pageSize}")
    List<ActivityDO> selectActivityList(@Param("offset") Integer offset,
                                        @Param("pageSize") Integer pageSize);

    /**
     * 根据活动id查活动信息
     * @param id
     * @return
     */
    @Select("select * from activity where id = #{id}")
    ActivityDO selectById(@Param("id") Long id);

    /**
     * 根据活动id，更新目标状态
     * @param id 活动id
     * @param status 目标状态
     */

    @Update("update activity set status = #{status} where id = #{id}")
    void updateStatus(@Param("id") Long id, @Param("status")String status);
}
